Skip to content

Use worktree path for card identity instead of branch name#78

Merged
0101 merged 3 commits into
mainfrom
path-based-card-identity
Jun 3, 2026
Merged

Use worktree path for card identity instead of branch name#78
0101 merged 3 commits into
mainfrom
path-based-card-identity

Conversation

@0101

@0101 0101 commented Jun 2, 2026

Copy link
Copy Markdown
Owner

Problem

Card identity was based on repoId/branch composite strings (e.g. "CloudPlatform/feature/retry-logic"). This breaks for detached-HEAD worktrees where multiple cards can share the same branch value "(detached)", causing focus, sync events, and card state to collide.

Changes

Path-based card identity — Replace repoId/branch keys with WorktreePath values throughout:

  • Navigation.fs: FocusTarget.Card now holds a worktree path; visibleFocusTargets, repoNavSections, and adjustFocusAfterCollapse use path-based lookups
  • App.fs: renderCard builds scopedKey from WorktreePath.value wt.Path; StartSync/SyncStatusUpdate use path keys
  • WorktreeApi.fs: getSyncStatus translates internal scopedBranchKey → worktree path before returning to client

Card title display — Add WorktreePath.displayName (extracts last path segment) and cardTitle helper:

  • Normal worktrees show branch name
  • Detached-HEAD worktrees show directory name from path

Review-driven cleanup:

  • Move DetachedBranchName constant to Shared.WorktreeStatus, eliminating duplicate literal in GitWorktree.fs
  • Move cardTitle from Shared/Types.fs to Client/Components.fs (UI function belongs with UI helpers)
  • Rename FocusTarget.Card field label from scopedKey to path
  • Fix DemoFixture.fs sync status keys to use worktree path values
  • Fix worktrees.json fixture SyncStatus keys to use full worktree paths

Tests

627 unit tests passing.

0101 added 3 commits June 2, 2026 16:45
Switch card identity from branch-based ({repoId}/{branch}) to path-based
(WorktreePath.value). Worktree paths are globally unique (filesystem
guarantee) and stable across git operations, solving issues with detached
HEAD worktrees that all shared the same '(detached)' branch name.

- Add WorktreePath.displayName for card title display (last path segment)
- Update Navigation.fs card keys and adjustFocusAfterCollapse to use paths
- Update App.fs findWorktree, renderCard, and card views for path-based keys
- Update ArchiveViews.fs card keys and display text
- Change server getSyncStatus to return path-keyed response map
- Update NavigationTests and ArchiveTests for new key format
Add WorktreeStatus.cardTitle: uses wt.Branch when available, falls back
to WorktreePath.displayName for detached HEAD worktrees. This way 'main'
still shows as 'main', while detached worktrees show their directory
name (e.g. '.lm-ref-abc') instead of the unhelpful '(detached)'.
- Move DetachedBranchName constant to Shared.WorktreeStatus, remove
  duplicate from GitWorktree.fs
- Move cardTitle UI function from Shared/Types.fs to Client/Components.fs
- Rename FocusTarget.Card field label from scopedKey to path
- Fix DemoFixture sync status keys to use worktree paths
- Fix fixture JSON SyncStatus keys to use full worktree paths
@0101 0101 merged commit 6a8da00 into main Jun 3, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant